<?=$this->header(true)?>


    <?=$this->menu("content")?>


    <h1><?=$this->message("label.links", _Content::BUNDLE)?></h1>


    <? /* Breadcrums route */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.category.header", _Content::BUNDLE),
                "href"=>"content/category/index"
            ),
            array(
                "name"=>$this->category($this->linkForm->getContentLink()->getContent()->getCategoryId()),
                "href"=>"content/index"
            ),
            array(
                "name"=>$this->message("label.links.for", _Content::BUNDLE) . " \"" .
                    $this->truncateNicely($this->linkForm->getContentLink()->getContent()->getDefaultContentI18n($this->param(_Core::DEFAULT_LANGUAGE))->getName(), 20, 24, "...") . "\"",
                "href"=>"content/link/index"
            ),
            array(
                "name"=>($this->linkForm->getContentLink()->getContentLinkId() > 0 ?
                    $this->message("route.edit", _Core::BUNDLE) . " " .
                        "\"".$this->linkForm->getContentLink()->getName()."\" " :
                    $this->message("route.new", _Core::BUNDLE) . " " . $this->message("label.link", _Content::BUNDLE))
            )
        )
    )?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null, _Content::BUNDLE)?>

    <form id="<?=get_class($this->linkForm)?>" action="content/link/save" method="post" enctype="multipart/form-data">

        <fieldset>

            <legend><?=$this->message("label.required", _Core::BUNDLE)?></legend>

            <div>
                <input type="hidden"
                       name="contentLink->contentLinkId"
                       value="<?=$this->linkForm->getContentLink()->getContentLinkId()?>" />
                <input type="hidden"
                       name="contentLink->contentId"
                       value="<?=$this->linkForm->getContentLink()->getContentId()?>" />
            </div>

            <table cellspacing="0" cellpadding="0" class="form">
            <tr class="ctrl<?=$this->error("contentLink->name")?>">
                <th><label for="contentLink_name"><?=$this->message("prompt.link.name", _Content::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="contentLink->name"
                           id="contentLink_name"
                           value="<?=$this->linkForm->getContentLink()->getName()?>"
                           maxlength="255"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr>
            	<th></th>
            	<th></th>
            	<td><hr class="textInput" /></td>
           	</tr>
            <tr class="ctrl<?=$this->error("contentLink->link")?>">
                <th><label for="contentLink_link"><?=$this->message("prompt.link.link", _Content::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="contentLink->link"
                           id="contentLink_link"
                           value="<?=$this->linkForm->getContentLink()->getLink()?>"
                           maxlength="255"
                           type="text"
                           class="textInput" />
                    <p class="hint"><?=$this->message("note.url", _Core::BUNDLE)?></p>
                </td>
            </tr>
            <tr class="ctrl">
                <th><b><?=$this->message("label.or", _Core::BUNDLE)?></b></th>
                <th></th>
                <td></td>
            </tr>
            <tr class="ctrl<?=$this->error("internalLink")?>">
                <th><label for="internalLink"><?=$this->message("prompt.link.link.internal", _Content::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <?=$this->internalLinks()->modules($this->linkForm)?>
                    <br />
                    <?=$this->internalLinks()->links($this->linkForm)?>
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("contentLink->menuItemIds")?>">
                <th><label for="contentLink_menuItemIds"><?=$this->message("prompt.link.link.menuitem", _Content::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                	<select id="contentLink->menuItemIds" name="contentLink->menuItemIds" class="textInput">
                		<?=$this->menuItems($this->linkForm->getContentLink()->getMenuItemIds())?>
               		</select>
				</td>
            </tr>
            <tr>
            	<th></th>
            	<th></th>
            	<td><hr class="textInput" /></td>
           	</tr>
            </table>

        </fieldset>

        <div class="buttons">

            <input type="button"
                   onclick="to('content/link/index')"
                   value="<?=$this->message("button.cancel", _Core::BUNDLE)?>"
                   class="button" />
            <input type="submit"
                   value="<?=$this->message("button.submit", _Core::BUNDLE)?>"
                   class="button" />

        </div>

    </form>
    
    <?=$this->focus(get_class($this->linkForm), "contentLink->name")?>

<?=$this->footer()?>